package com.ymttest.business.service.productdata.service;

import java.io.File;
import java.util.List;

import com.ymttest.utils.FileUtil;
import com.ymttest.utils.compare.CompareHelper;
import com.ymttest.utils.compare.LogPathConf;
import com.ymttest.utils.compare.LoggerHelper;
import com.ymttest.utils.compare.LoggerInterface;

public class CreateProduct3 {
	
	
	
	
	
	public static void main(String args[]) {
		LogPathConf logPathConf = new LogPathConf(true);
		LoggerInterface logger = new LoggerHelper(logPathConf);
		CompareHelper compareHelper = new CompareHelper(logger, 5);
		
		
		//catalogIdAndPriceAndNameFile
		String catalogIdAndPriceAndNameFile = System.getProperty("user.dir") + File.separator + "resource" + File.separator
						+ "CompareData" + File.separator + "catalogIdAndPriceAndName.txt";

		List<String> catalogIdAndPriceAndNameFileList = FileUtil.readFileAsLine(catalogIdAndPriceAndNameFile);
		
		//brandId
		String priceAndNameFile = System.getProperty("user.dir") + File.separator + "resource" + File.separator
				+ "CompareData" + File.separator + "priceAndName.txt";

		List<String> priceAndNameFileList = FileUtil.readFileAsLine(priceAndNameFile);
		
			
		
		
		for (int i=0;i<priceAndNameFileList.size();i++){
			String[] tgtArys = priceAndNameFileList.get(i).split(",");
			double tgtPrice = Double.parseDouble(tgtArys[0]);
			String tgtName = String.valueOf(tgtArys[1]);
			
			boolean isFound = false;
			for (int k = 0;k<catalogIdAndPriceAndNameFileList.size();k++){
				String[] actArys = catalogIdAndPriceAndNameFileList.get(k).split(",");
				String catalogId = actArys[0];
				double actPrice = Double.parseDouble(actArys[1]);
				String actName = String.valueOf(actArys[2]);
				
				if (actPrice==tgtPrice&&actName.equals(tgtName)){
					logger.comment(catalogId+","+actPrice);
					isFound = true;
					break;
				}
			}
			
			if (!isFound){
				logger.comment("not found "+tgtPrice+","+tgtName);
			}
		}
		

		
	}
}
